/* Reset and base styles for consistent rendering */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    user-select: none;
}

/* Main container with responsive height for iframe/standalone */
.game-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    max-height: 90vh; /* Standalone browser height */
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

/* Compact header design to save vertical space */
.game-header {
    display: flex;
    justify-content: space-around;
    padding: 8px 16px;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stat-item {
    text-align: center;
    cursor: help;
    transition: transform 0.2s ease;
}

.stat-item:hover {
    transform: scale(1.05);
}

.stat-label {
    display: block;
    font-size: 10px;
    opacity: 0.8;
    font-weight: 500;
}

.stat-value {
    display: block;
    font-size: 16px;
    font-weight: bold;
    margin-top: 2px;
}

/* Main game area with flexible layout */
.game-area {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow-y: auto;
}

/* MCQ Phase Styles */
.mcq-phase {
    text-align: center;
    animation: fadeIn 0.5s ease-in;
}

.word-display h2 {
    font-size: 28px;
    color: #333;
    margin-bottom: 20px;
    padding: 12px;
    background: linear-gradient(45deg, #ffeaa7, #fdcb6e);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: help;
}

.definition-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 100%;
}

/* Button styling optimized for touch and limited height */
.option-btn {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(45deg, #74b9ff, #0984e3);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-height: 44px; /* Touch-friendly minimum */
    text-align: left;
    word-wrap: break-word;
    line-height: 1.3;
}

.option-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    background: linear-gradient(45deg, #0984e3, #74b9ff);
}

.option-btn:active {
    transform: translateY(0);
}

.option-btn.correct {
    background: linear-gradient(45deg, #00b894, #00cec9);
    animation: correctPulse 0.6s ease;
}

.option-btn.incorrect {
    background: linear-gradient(45deg, #e17055, #d63031);
    animation: incorrectShake 0.6s ease;
}

/* Typing Phase Styles */
.typing-phase {
    animation: slideIn 0.5s ease-in;
}

.sentence-display {
    margin-bottom: 16px;
}

.sentence-display p {
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid #74b9ff;
    cursor: help;
}

.typing-area {
    margin-bottom: 12px;
}

#typingInput {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    resize: vertical;
    transition: border-color 0.3s ease;
    background: #fff;
}

#typingInput:focus {
    outline: none;
    border-color: #74b9ff;
    box-shadow: 0 0 0 3px rgba(116, 185, 255, 0.2);
}

.typing-stats {
    display: flex;
    justify-content: space-around;
    font-size: 12px;
    color: #666;
}

.typing-stat {
    font-weight: 500;
}

/* Game Over Screen */
.game-over {
    text-align: center;
    animation: fadeIn 0.5s ease-in;
}

.final-stats h2 {
    color: #333;
    margin-bottom: 16px;
    font-size: 24px;
}

.final-score {
    font-size: 32px;
    font-weight: bold;
    color: #00b894;
    margin-bottom: 16px;
}

.performance-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #666;
}

.restart-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(45deg, #00b894, #00cec9);
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Progress bar */
.progress-container {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.9);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: help;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00b894, #00cec9);
    transition: width 0.5s ease;
    border-radius: 4px;
}

.progress-text {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    white-space: nowrap;
}

/* Celebration overlay */
.celebration {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 184, 148, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: celebrationPulse 1s ease-in-out;
}

.celebration-content {
    text-align: center;
    color: white;
}

.celebration-text {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 8px;
}

.points-earned {
    font-size: 18px;
    opacity: 0.9;
}

/* Instructions help icon */
.instructions {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    font-size: 12px;
    font-weight: bold;
    color: #666;
    transition: all 0.3s ease;
}

.instructions:hover {
    background: white;
    transform: scale(1.1);
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes celebrationPulse {
    0% { opacity: 0; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .game-container {
        border-radius: 0;
    }
    
    .word-display h2 {
        font-size: 22px;
    }
    
    .option-btn {
        font-size: 13px;
        padding: 10px 12px;
    }
    
    .sentence-display p {
        font-size: 14px;
    }
    
    #typingInput {
        font-size: 13px;
        min-height: 70px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .option-btn {
        border: 2px solid #333;
    }
    
    .progress-bar {
        border: 1px solid #333;
    }
}